<!--ules
 * @Author: lsy
 * @Date: 2023-02-14 22:35:38
 * @LastEditors: lsy
 * @LastEditTime: 2023-02-16 19:43:37
 * @Description: 请填写简介
-->
<template>
	<sc-basic-form
    :formItems="studentFormItems"
    :model="studentModel"
    label-width="140"
    ref="formRef"
  >
  </sc-basic-form>
</template>

<script setup>
import { ref, computed,  defineProps, defineEmits, defineExpose } from "vue";

import { studentFormItems} from "./data";

const props = defineProps({
  studentInfo: {
    type: Object,
    default: () => ({})
  }
})

const emits = defineEmits(['update:studentInfo'])

const studentModel = computed({
  get() {
    return props.studentInfo
  },
  set(val) {
    emits('update:studentInfo', val)
  }
})

let introdStudent = ref({})
let introEmployee = ref({})

const formRef = ref(null)

function introdStudentChange(sudent) {
	introdStudent.value = {
		name: sudent.name + " " + sudent.phone,
		id: sudent.studentId,
  };
  emits('update:studentInfo', {
    ...studentModel.value,
    recommendStudentId: sudent.studentId,
  })
}
function introEmployeeChange(employee) {
	introEmployee.value = {
		memberName: employee.memberName + " " + employee.memberPhone,
		id: employee.id,
  };
}
function resetForm(form, resetValue = {}) {
	Object.keys(form).forEach((key) => {
		form[key] = resetValue[key] ?? "";
	});
}
function validate(callBackObj) {
  formRef.value.validate(callBackObj)
}

defineExpose({
  validate
})
</script>

<style lang="scss" scoped>
.mr10 {
	margin-right: 10px;
}
</style>
